package com.template.app.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.template.app.i18n.I18N;
import com.template.app.i18n.I18NKey;

public class DateUtils {
	
	public static Date getCurrentDate() {
		return new Date();
	}

	public static String formatDate(Date date) {
		return format(I18NKey.DATE_FORMAT, date);
	}

	public static String formatDateTime(Date date) {
		return format(I18NKey.DATE_TIME_FORMAT, date);
	}

	public static String formatDateTimeMilli(Date date) {
		return format(I18NKey.DATE_TIME_MILLI_FORMAT, date);
	}

	public static String formatDateTimeSec(Date date) {
		return format(I18NKey.DATE_TIME_SEC_FORMAT, date);
	}

	public static String formatTime(Date date) {
		return format(I18NKey.TIME_FORMAT, date);
	}

	public static String formatTimeMilli(Date date) {
		return format(I18NKey.TIME_MILLI_FORMAT, date);
	}

	public static String formatTimeSec(Date date) {
		return format(I18NKey.TIME_SEC_FORMAT, date);
	}
	
	private static String format(String i18nKey, Date date) {
		return new SimpleDateFormat(I18N.getString(i18nKey)).format(date);
	}
}
